package com.enlighten.featureExtractor.coinFeature;

import java.awt.Color;

import com.enlighten.featureExtractor.ICoinFeature;

public class RadiusBasedCoinFeature implements ICoinFeature<RadiusBasedCoinFeature> {

	private int id;
	private double blacks;
	private double whites;

	public RadiusBasedCoinFeature(int id) {
		this.id = id;
		this.blacks = 0;
		this.whites = 0;
	}

	@Override
	public Double distanceTo(RadiusBasedCoinFeature feature) {
		return Math.sqrt(getDensity()*getDensity() + feature.getDensity()*feature.getDensity());
	}

	public double getDensity() {
		if ( blacks+whites == 0 )
			return 0;
		return whites/(blacks+whites);
	}

	@Override
	public int getId() {
		return id;
	}

	public void addPoint(int x, int y, int rgb) {
		if (rgb == Color.BLACK.getRGB())
			blacks++;
		else
			whites++;
	}

}
